﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jayden.Dll.XmlScript.Descriptions;
using System.Xml;

namespace Jayden.Dll.XmlScript
{
	public class XmlScriptLoader
	{
		private List<XmlExpressionDescription> m_Expressions = new List<XmlExpressionDescription>();

		public XmlScriptLoader()
		{
			m_Expressions.Add(XmlObjectDescription.Instance);
			m_Expressions.Add(XmlAdditionDescription.Instance);
			m_Expressions.Add(XmlSubtractionDescription.Instance);
			m_Expressions.Add(XmlMultiplucationDescription.Instance);
			m_Expressions.Add(XmlDivisionDescription.Instance);
		}

		public XmlExpression LoadExpression(XmlElement element)
		{
			foreach (XmlExpressionDescription description in m_Expressions)
				if (description.IsToken(element))
					return description.Load(this, element);
			return null;
		}
	}
}
